package com.ruoyi.manage.controller;


import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.cg.pojo.*;
import com.ruoyi.common.core.cg.result.Queryparam;
import com.ruoyi.common.core.cg.result.Result;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.manage.service.IStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 管理Controller
 *
 * @author ruoyi
 * @date 2025-03-09
 */
@RestController
@RequestMapping("/store")
public class StoreController extends BaseController
{
    @Autowired
    private IStoreService storeService;

    /**
     * 查询管理列表
     */
    @RequestMapping("/list")
    public Result list(@RequestBody Queryparam queryparam)
    {
        PageInfo<Store> pageInfo = storeService.selectStoreList(queryparam);
        return new Result(true,"查询成功",pageInfo);
    }

    @RequestMapping("byName")
    public Result byName(Integer name){
        Store byName = storeService.byName(name);
        return new Result(true,"查询成功",byName);
    }

    @RequestMapping("Selectclass")
    public Result Selectclass(){
        List<Classification> classifications = storeService.Selectclass();
        return new Result(true,"查询成功",classifications);
    }
    @RequestMapping("SelectLeader")
    public Result SelectLeader(Integer id){
        Leader leader = storeService.SelectLead(id);
        return new Result(true,"查询成功",leader);
    }

    @RequestMapping("updateStore")
    public Result updateStore(@RequestBody Store store){
        boolean updateStore = storeService.updateStore(store);
        if (updateStore){
            return new Result(true,"修改成功");
        }else {
            return new Result(false,"修改失败");
        }
    }

}
